package com.zzptc.zzsgz.bdsjws.activities;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.MotionEvent;

import com.zzptc.zzsgz.bdsjws.MyApplication;
import com.zzptc.zzsgz.bdsjws.R;
import com.zzptc.zzsgz.bdsjws.activities.base.BaseActivity;
import com.zzptc.zzsgz.bdsjws.adapter.BbxAdapter;
import com.zzptc.zzsgz.bdsjws.db.BoxDao;
import com.zzptc.zzsgz.bdsjws.listener.OnRecyclerItemClickListener;
import com.zzptc.zzsgz.bdsjws.utils.DividerGridItemDecoration;
import com.zzptc.zzsgz.bdsjws.vo.Box;

import java.util.List;

import butterknife.BindView;

public class BoxActivity extends BaseActivity {
    List<Box> list;
    @BindView(R.id.rv_bbx)
    RecyclerView rvBbx;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Override
    public int getContentXML() {
        return R.layout.activity_box;
    }

    @Override
    public void initData() {
        //到数据库中取数据出来  得到百宝箱dao
        BoxDao boxDao = MyApplication.getDaoSession().getBoxDao();
        list = boxDao.loadAll();
        // LinearLayoutManager linearLayoutManager=new LinearLayoutManager(this);x
        BbxAdapter bbxAdapter = new BbxAdapter(list);
        RecyclerView.LayoutManager layoutManager = new GridLayoutManager(this, 4);
        rvBbx.setLayoutManager(layoutManager);
        rvBbx.addItemDecoration(new DividerGridItemDecoration(this));
        rvBbx.setAdapter(bbxAdapter);
//        rvBbx.addOnItemTouchListener(new OnRecyclerItemClickListener(rvBbx){
//
//            @Override
//            public void onItemClick(RecyclerView.ViewHolder vh) {
//                super.onItemClick(vh);
//                Box box=list.get(vh.getPosition());
//                if (box.getName().equals("家人守护")){
//                    startActivity(new Intent(BoxActivity.this,FamilyActivity.class));
//                }
//            }
//
//            @Override
//            public void onLongClick(RecyclerView.ViewHolder vh) {
//                super.onLongClick(vh);
//            }
//        });

    }

    @Override
    public void intView() {

    }
}
